import { GlobalAction } from '../actions'
import { GlobalType } from '../Types'
import { 
  RecordBand,
  GetSampleImg_FULFILLED,
  RecordSample_FULFILLED,
  GetWorkStatus_FULFILLED,
  GetSampleScore_FULFILLED,
  GetHxjcfq_FULFILLED,
  GetRoleScore_FULFILLED,
  GetSampleChecked_FULFILLED,
  GetYyHxJx_FULFILLED,
  InitDict_FULFILLED,
  RECORD_Pull_Data_FULFILLED,
  GetReasonList_FULFILLED } from '../Constants'
// 初始化
const initState= {
  band: {
    id: '',
    no: ''
  },
  sample: {},
  Hxjcfq:{},
  sampleImgs: {},
  workStatus: [],
  checkList: [],
  reasonList: [],
  sampleScore: [],
  roleScore: [],
  yyhxjx: [],
  dicts: {},
  pullData: []
}

export function GlobalReducer (state: GlobalType = initState, action: GlobalAction): GlobalType {
  switch(action.type) {
    case RecordBand :
      return { ...state, band: action.payload }
    case GetSampleImg_FULFILLED :
      return { ...state, sampleImgs: action.payload }
    case RecordSample_FULFILLED :
      return { ...state, sample: action.payload }
    case GetWorkStatus_FULFILLED :
      return { ...state, workStatus: action.payload }
    case GetSampleScore_FULFILLED :
      return { ...state, sampleScore: action.payload }
    case GetHxjcfq_FULFILLED :
      return { ...state, Hxjcfq: action.payload }
    case GetRoleScore_FULFILLED :
      return { ...state, roleScore: action.payload }
    case GetSampleChecked_FULFILLED :
      return { ...state, checkList: action.payload }
    case GetYyHxJx_FULFILLED :
      return { ...state, yyhxjx: action.payload }
    case InitDict_FULFILLED: 
      return { ...state, dicts: action.payload }
    case RECORD_Pull_Data_FULFILLED:
      return { ...state, pullData: action.payload }
    case GetReasonList_FULFILLED:
      return { ...state, reasonList: action.payload }
  }
  return state
}